package com.rt.cloud.auth.filter;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.filter.OncePerRequestFilter;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * filter
 */
@Slf4j
//@Component
//@Order(Integer.MIN_VALUE)
public class CrosFilterServlet extends OncePerRequestFilter {


    @Override
    protected void doFilterInternal(HttpServletRequest request,
                                    HttpServletResponse response,
                                    FilterChain filterChain) throws ServletException, IOException {

        /*String servletPath = request.getServletPath();

        log.info("auth servletPath:{}", servletPath);

        //通过getHeaderNames获得所有头名字的Enumeration集合
        Enumeration<String> headNames = request.getHeaderNames();
        while(headNames.hasMoreElements()){
            String headName = headNames.nextElement();
            System.out.println(headName+":"+request.getHeader(headName));
        }

        filterChain.doFilter(request, response);// 替换原始请求参数*/
    }

}
